<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div id="root">
        <!-- <h1>{{msg}}</h1> -->
        <app></app>
    </div>

    <script type="text/javascript">
        Vue.config.productionTip = false;  //阻止Vue在启动时生成 生产提示

        //这里school管理着student组件，就要在school里面注册，使用。注意：student要在管理前创建
        const student = Vue.extend({
            name: 'student',
            template: `
            <div>
                <h2>学生名称：{{name}}</h2>
                <h2>年龄：{{age}}</h2>
            </div>
            `,
            data() {
                return {
                    name: '尚硅谷',
                    age: 18
                }
            }
        });

        const school = Vue.extend({
            name: 'school',
            template: `
            <div>
                <h2>学校名称：{{name}}</h2>
                <h2>学校名称：{{address}}</h2>
                <student></student>
            </div>
            `,
            data() {
                return {
                    name: '尚硅谷',
                    address: '北京'
                }
            },
            components: {
                student
            }
        });

        const hello =Vue.extend({
            template:  `<h1>{{msg}}</h1>`,
            data(){
                return{
                    msg:'欢迎来到页面！'
                }
            }
        })

        const app=Vue.extend({
            template:`
            <div>
                <hello></hello>
                <school></school>
            </div>
            `,
            components:{
                school,
                hello
            }
        })
        //创建Vue实例
        new Vue({
            //如果在root模型上不写app 那就在这里写
            // template:`<app></app>`
            el: '#root',
            data: {
                msg: '欢迎学习Vue!'
            },
            components: {
                app
            }
        })
    </script>
</body>

</html>